<script type="text/javascript" src="__PUBLIC__/js/plupload/plupload.full.min.js"></script>
<script type="text/javascript">
    var uploader = new plupload.Uploader({
        runtimes: 'html5,flash,silverlight,html4',
        browse_button: 'btn_logo', // you can pass in id...
        multi_selection: false,
        container: document.getElementById('container'), // ... or DOM Element itself
        url: "{:U('Upload/member_avatar')}",
        flash_swf_url: '__PUBLIC__/js/plupload/Moxie.swf',
        silverlight_xap_url: '__PUBLIC__/js/plupload/Moxie.xap',
        filters: {
            max_file_size: '10mb',
            mime_types: [
                {title: "Image files", extensions: "jpg,gif,jpeg"},
//                                                    {title: "Zip files", extensions: "zip"}
            ]
        },
        init: {
            FilesAdded: function(up, files) {
                uploader.start();
            },
            UploadProgress: function(up, file) {
                //file.percent
//                $("#file-img").attr("src","__PUBLIC__/images/loading.gif");

            },
            FileUploaded: function(up, file, info) {
                var data = JSON.parse(info.response);
                if (data.error) {
                    alert(data.error);
                } else {

                    $("#avatarImg").attr("src", data.pic);
                }

            },
            Error: function(up, err) {
                if(err.code == -601){
                    alert("只能上传jpg,gif,jpeg格式图片！");
                }
                
//                console.log(err.error);
                // document.getElementById('console').innerHTML += "\nError #" + err.code + ": " + err.message;
            }
        }
    });

    uploader.init();


</script>